package o;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

public final class hg {

    public interface e<T> {
        boolean ˋ(@NonNull T t);

        @Nullable
        T ˎ();
    }

    public static class c<T> implements e<T> {
        private final Object[] ˊ;
        private int ˎ;

        public c(int i) {
            if (i <= 0) {
                throw new IllegalArgumentException("The max pool size must be > 0");
            }
            this.ˊ = new Object[i];
        }

        public T ˎ() {
            if (this.ˎ <= 0) {
                return null;
            }
            int i = this.ˎ - 1;
            T t = this.ˊ[i];
            this.ˊ[i] = null;
            this.ˎ--;
            return t;
        }

        public boolean ˋ(@NonNull T t) {
            if (ॱ(t)) {
                throw new IllegalStateException("Already in the pool!");
            } else if (this.ˎ >= this.ˊ.length) {
                return false;
            } else {
                this.ˊ[this.ˎ] = t;
                this.ˎ++;
                return true;
            }
        }

        private boolean ॱ(@NonNull T t) {
            for (int i = 0; i < this.ˎ; i++) {
                if (this.ˊ[i] == t) {
                    return true;
                }
            }
            return false;
        }
    }

    public static class b<T> extends c<T> {
        private final Object ˊ = new Object();

        public b(int i) {
            super(i);
        }

        public T ˎ() {
            T ˎ;
            synchronized (this.ˊ) {
                ˎ = super.ˎ();
            }
            return ˎ;
        }

        public boolean ˋ(@NonNull T t) {
            boolean ˋ;
            synchronized (this.ˊ) {
                ˋ = super.ˋ(t);
            }
            return ˋ;
        }
    }
}
